﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSVideoUploader.Client.Xina
{
    /// <summary>
    /// XinaClient子类，使用微博接口上传视频
    /// 走这个接口将拿不到vid，需要自行去播客中查看
    /// </summary>
    class WeiboXinaClient : XinaClient
    {
        #region 接口URL
        /// <summary>看点URL</summary>
        const string KANDIAN_URL = "http://app.kandian.com/app/weibo_upload/upload?pid=&publish=";
        /// <summary>上传预处理URL</summary>
        const string PRE_UPLOAD_URL = "http://upload.kandian.weibo.com/app/weibo_upload/get_upload_url?id=0&__rnd=";
        /// <summary>提交信息的URL</summary>
        const string SAVE_URL = "http://upload.kandian.weibo.com/app/weibo_upload/save_weibo";
        #endregion

        public WeiboXinaClient(string username)
            : base(username)
        {}

        /// <summary>
        /// 执行上传
        /// </summary>
        /// <param name="task"></param>
        /// <param name="handler"></param>
        public override void Upload(XinaUploadTask task, Http.IUploadProgressListener listener)
        {
            // 访问看点地址，让它设置几个cookie
            client.Get(KANDIAN_URL);

            // 上传前预处理，请求hach值和上传地址
            string body = client.Get(PRE_UPLOAD_URL + DateTime.Now.ToBinary());
            Console.WriteLine(body);
        }
    }
}
